home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / hardware / joysdk11 / readme < prev    next >
Encoding:
Text File  |  1993-10-02  |  12.5 KB  |  260 lines

  1.                                            A d v a n c e d
  2.                    ▄▄▄▄  ▄▄▄▄▄    ▄▄▄▄  ▄▄    ▄▄ ▄  ▄▄▄▄▄
  3.                   ▐  ▄▄  ▐    ▌  ▐█  █▌ ▐█    █▌ █ ▐▄▄▄▄▄
  4.                   ▐    ▌ ▐▀▀█▀  ▐█    █▌ ▐█  █▌  █       ▌
  5.                    ▀▀▀▀  ▀   ▀  ▀      ▀  ▀▀▀▀   ▀  ▀▀▀▀▀
  6.                   Advanced Gravis Computer Technology Ltd.
  7.  
  8.       Fax (604) 435-9358                   BBS  (604) 431-5927 V32bis
  9.       Compuserve: GO PCVENB (71333,350)    InterNET EMail: tech@gravis.com
  10.       FidoNET: 1:153/978 or 1:153/878      SBCNET: 13:900/3
  11.  
  12.                 PC GamePad and Analog Pro SDK V1.1 (JOYSDK11.ZIP)
  13.  
  14.                          1.0 Installation Notes
  15.                          2.0 Support
  16.                          3.0 What is Included with this SDK
  17.                          4.0 PC GamePad and PC Analog Pro Documentation
  18.  
  19. 1.0.0 Installation
  20. ------------------
  21. Simply type INSTALL to install the SDK.  It will default to C:\JOYSDK
  22. and will require 100k of hard disk space.  All the documentation may
  23. be found in this README.
  24.  
  25. 2.0.0 Support
  26. -------------
  27. Due to the low cost of the PC GamePad and Analog Pro developers toolkit
  28. (free) we do not offer much in the way of technical support.  All the
  29. documentation, and source code 'as is'.  We do provide a Gravis
  30. programming message and file area on our BBS and on all the Gravis
  31. nodes.  Please refer to GRAVNODE.TXT for more information on how
  32. to reach us via electronic mail.
  33.  
  34. 3.0.0 What is Included with this SDK
  35. ------------------------------------
  36. This SDK includes:
  37.  
  38.    ■ Technical information about the PC GamePad and Analog Pro
  39.    ■ Technical information on the PC gameport
  40.    ■ Pin out for a PC gameport
  41.    ■ ASM and C routines on how to access the PC gameport
  42.  
  43. 4.0.0 PC GamePad and PC Analog Pro Documentation
  44. ------------------------------------------------
  45.  
  46.    PC GamePad and Analog Pro Technical Notes for Software Development
  47.  
  48. Introduction
  49. ============
  50.  
  51. The PC GamePad and PC Analog Pro by Advanced Gravis Computer Technology
  52. Ltd. are position input devices for PCs and compatibles. The GamePad
  53. is a joystick-like device optimized for 'switch stick' mode games and
  54. user input applications.  While the Analog Pro is a proportional style
  55. stick built for software that require more precision, such as flight
  56. simulators. This following technical note provides a description of
  57. the GamePad and Analog Pro's hardware and software interface.  This
  58. note should assist software developers in implementing the Gravis PC
  59. GamePad and Analog Pro in their software projects.
  60.  
  61. The Analog Pro
  62. ==============
  63.  
  64. The Analog Pro behaves much like a regular analog style joystick but
  65. with a few exceptions.  First the Analog Pro comes with 5 fire buttons,
  66. while most joysticks only come with 2.  Two of these buttons can be
  67. configured to act as button 1A,1B,2A or 2B.  See table below for an
  68. explanation on how this is done. You may also refer to your manual
  69. to find the layout and defaults for each of the 5 buttons.  Secondly
  70. the Analog Pro can use the Y-Axis of Joystick B as a throttle control.
  71. The user, by turning a dial on the Analog Pro, can change the value of
  72. this axis. It was intended to be used as a throttle control but could
  73. just as easily be used for some different purpose in your software.
  74. Below is a table explaining how to access these extra features of
  75. the Analog Pro.  Remember that only the 2 buttons on the base of the
  76. Analog Pro are selectable.  The 3 on the handle are fixed.
  77.  
  78.         -- B & A               Analog Pro  Standard Gameport
  79.        ___                      ----------------------------------
  80.   C -> \ |                      X-Axis      Joystick A, X-Axis
  81.         ||       A = Button 1A  Y-Axis      Joystick A, Y-Axis
  82.    D - || - E  B = Button 2A  Throttle    Joystick B, Y-Axis
  83.      _▄_||_▄_    C = Button 1A  Button 1A   Joystick A, Button #1A
  84.      |______|                   Button 1B   Joystick A, Button #2A
  85.                                 Button 2A   Joystick B, Button #1B
  86.      Left Side                  Button 2B   Joystick B, Button #2B
  87.  
  88. The PC GamePad
  89. ==============
  90.  
  91. The PC GamePad is a device very similar to an anolog joystick.  It plugs
  92. into a standard PC gameport like a joystick.  The difference between a
  93. typical joystick and the GamePad exists mostly in the axis characteristics.
  94. Joysticks normally have X and Y axes that consist of continuously variable
  95. axis resistances, which in turn yields continuously variable X and Y
  96. positions.  The GamePad, however, provides 'fixed' resistances
  97. (non-proportional) for nine distinct GamePad controller positions
  98. (including center). The fixed resistances are set to approx. 0 ohms,
  99. approx. 50k ohms, and approx. 100k ohms.  Also, there are some differences
  100. in the buttons' arrangement. Four independant buttons are available, two
  101. of which can be configured as 'autofire' (slide switch selector).
  102. Furthermore, another slide switch allows the GamePad to be set for
  103. left-hand or right-hand use. Below is a table explaining how to read
  104. the extra buttons on the PC GamePad.
  105.  
  106.                                 PC GamePad
  107.                             4 Button   Turbo Fire  Standard Gameport
  108.    _____     ||             ----------------------------------------------
  109.   |     \____||________     X-Axis     X-Axis      Joystick A, X-Axis
  110.   |  __    GRAVIS      \    Y-Axis     Y-Axis      Joystick A, Y-Axis
  111.   | /  \  GamePad   B  |    Button A   Button A    Joystick A, Button #1A
  112.   | \__/          A   C|    Button B   Button B    Joystick A, Button #2A
  113.   |______________   D  |    Button D   Auto B      Joystick B, Button #1B
  114.                  \_____|    Button C   Auto A      Joystick B, Button #2B
  115.  
  116.  
  117. The Gameport
  118. ============
  119.  
  120. IBM defined the gameport as it exists on IBM PCs and compatibles.
  121. Their definition includes a connector spec, and a PC bus interface spec.
  122. Several PC and compatible product vendors provide gameport hardware such
  123. as multi-I/O cards, sound cards, and game cards. Some gameport hardware
  124. comes with features like computer speed compensation. For instance,
  125. Gravis makes a game card called the "Eliminator Game Card" that has
  126. speed compensation, and "UltraSound" a sound card that has a speed
  127. compensated gameport.
  128.  
  129. The portion of the gameport interface of interest to programmers is the
  130. PC bus interface. The majority of this tech note deals with the programmers
  131. interface to the gameport, with some special references to the PC GamePad
  132. and Analog Pro.
  133.  
  134. The gameport appears to the PC bus as a single read and write address at I/O
  135. address 201 hex, and is 8 bits wide. Bit 0 thru bit 3 represent the axes.
  136. Bit 4 thru bit 7 represent buttons. Button positions can be determined at
  137. any time by reading location 201 hex and testing bits 4,5,6 and 7 for
  138. high or low logic states. A high state being pressed and a low being
  139. not pressed. Because you may be dealing with micro switch style buttons
  140. you MUST DEBOUNCE in software.
  141.  
  142. Reading gameport axis information is more complex.
  143.  
  144. To gain a better grasp of the procedure for axis reading, the following
  145. discusses gameport operation.
  146.  
  147. Joystick and other postional input devices are resistive transducers.
  148. Varying an axis position causes a varying resistance.
  149. The gameport connects to one end of this varying resistance.  Within
  150. the gameport circuitry exist 'one-shot' timers (flip-flop type logic
  151. device with a resistor & capacitor time out circuit) for each of the
  152. four axes. The joystick axis resistance determines the charge up time of
  153. the capacitor. Gameport axis information is represented by capacitor charge
  154. up time, and is determined by reading the axis timer status bits at
  155. address 201 hex. The axis bits are read as high when the capacitors
  156. are charging up, and the bits go low when the capacitor charges to a
  157. pre-determined level. Thus, the high time of the axis bits directly
  158. represents the axis resistance or position. The program can input axis
  159. position information into a program by repeatatively looping and
  160. reading the axis bits while high, and counting loop iterations.
  161. The higher the loop count, the higher the axis resistance.  Note that
  162. the gameport must be written to (output any value to address 201 hex.
  163. 0 value recommended) in order to start a time out cycle.
  164.  
  165. The following psuedocode provices a simplified example of how to
  166. read an axis:
  167.  
  168.         clear loop_cout
  169.         output (0, 201h)
  170.         loop {
  171.             axis_bit = input(201h)
  172.             incr loop_count
  173.         } while (axis bit high)
  174.         return loop_count
  175.  
  176. The previous example is perhaps the simplest possible implementation of the
  177. gameport's axis reading.  Included with this package are two software
  178. examples; assembler code driver for gameport reading and C code for
  179. implementing driver and providing operator interface.
  180.  
  181. A typical gameport without speed compensation may have a time out
  182. period of approx. 1.3 millisecond for an axis resistance of 100k ohms.
  183. If you have an Apple/IBM combo stick this timeout can be as long as 2ms.  A
  184. disconnected or defective gameport would have a much greater or infinite
  185. time out period. The programmer should take this into account and limit
  186. the maximum number of axis read loop iterations to take no more than
  187. several milliseconds.  Generally, if a time out takes too long, zero
  188. should be returned.  Looping ought not continue endlessly as the computer
  189. will appear hung.  For more computer time efficiency, all axes COULD BE
  190. read CONCURRENTLY using a more sophisticated driver.  However, reading
  191. them consecutively is more reliable. The maximum times an axis needs to
  192. be read is 20/second.  10/second will work fine and you may be able to
  193. get away with 5/second.
  194.  
  195. CAUTION: The faster the machine the faster the loop count!  Hence speed
  196.          compensating gameports.
  197.  
  198. Optimizing for the PC GamePad
  199. =============================
  200.  
  201. The provided examples are for general analog joystick applications.  It is
  202. possible to find optimizations for the PC GamePad.  Optimizations are
  203. possible because each GamePad axis has only 3 typical resistances
  204. (approx. 0 ohms, approx. 50k ohms, approx. 100k ohms).  Typical
  205. joystick drivers return analog values representing axis position.
  206. The programmer would have to do 'window' comparisons of values to
  207. determine the GamePad axis positions, which could consume valuable
  208. CPU time.  A PC GamePad specific driver could handle this window or
  209. limit comparison and return data relating to the nine possible
  210. positions only.
  211.  
  212.  
  213. GamePort - PC bus
  214. =================
  215.  
  216.    Read bits at address 201 (gameport)
  217.    ===================================
  218.  
  219.    =================================
  220.    | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  221.    =================================
  222.      |   |   |   |   |   |   |   |
  223.      |   |   |   |   |   |   |   +---- Axis       Joystick A, X-Axis
  224.      |   |   |   |   |   |   +-------- Timer      Joystick A, Y-Axis
  225.      |   |   |   |   |   +------------ Status     Joystick B, X-Axis
  226.      |   |   |   |   +---------------- Bits       Joystick B, Y-Axis
  227.      |   |   |   |
  228.      |   |   |   +-------------------- Digital    Joystick A, Button #1
  229.      |   |   +------------------------ Button     Joystick A, Button #2
  230.      |   +---------------------------- Inputs     Joystick B, Button #1
  231.      +--------------------------------            Joystick B, Button #2
  232.  
  233.  
  234.    D15 Connector
  235.    =============
  236.  
  237.                      FRONT (Female) on Gameport
  238.                      __________________________
  239.                      \ 8  7  6  5  4  3  2  1 /
  240.                       \ 9  10 11 12 13 14 15 /
  241.                        ----------------------
  242.  
  243.      Pin #  PC GamePad    PC Analog Pro     Standard Joystick
  244.     --------------------------------------------------------------
  245.       1     +5v           +5v               +5v
  246.       2     Button A      Button A          Joystick A, Button #1A
  247.       3     X-Out         X-Out             Joystick A, X-Axis
  248.       4     Gnd           Gnd               Gnd
  249.       5     N/A           N/A               Gnd
  250.       6     Y-Out         Y-Out             Joystick A, Y-Axis
  251.       7     Button B      Button B          Joystick A, Button #2A
  252.       8     N/A           N/A               +5v
  253.       9     N/A           N/A               +5v
  254.       10    Button C      Button C          Joystick B, Button #1B
  255.       11    N/A           N/A               Joystick B, X-Axis
  256.       12    Chassis Gnd   Gnd               Gnd
  257.       13    N/A           Throttle Control  Joystick B, Y-Axis
  258.       14    Button D      Button D          Joystick B, Button #2B
  259.       15    N/A           N/A               +5v
  260.